<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            height:1200px
        }
  
      </style>
</head>
<body>
    
<input id="txt" type="text" value="10"  />
<input type="button" value="开始" onclick="startF()" />

</body>
</html>
<script>
    // 记录当前秒数
   var seconds;
   function startF(){
       //1、把文本框的值赋给变量（初值）
       seconds =parseInt(document.getElementById("txt").value);
        var myTimer =setInterval(function(){
            //把second减一
            seconds--;
            if(seconds<=0){
                seconds=0
                window.clearInterval(myTimer);
            }
            //显示
            document.getElementById("txt").value =seconds;
        },1000)
   }
</script>